﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


using System.Data;
using System.Data.SqlClient;


namespace Demo
{
    
    class fengzhuang
    {
        //打开数据库链接
        public SqlConnection connection()
        { 
          string str="Data Source=LAPTOP-J3IVDBQO;Initial Catalog=demo;Integrated Security=True";
          SqlConnection sc = new SqlConnection(str);
          sc.Open();
          return sc;
        }
        //命令  sql是语句
        public SqlCommand command(String sql)
        {
            SqlCommand sc = new SqlCommand(sql, connection());
            return sc;
        }
        //增删改  sql是语句   函数返回受影响行数
        public int Excute(string sql)
        { return command(sql).ExecuteNonQuery(); }
        //查du   sql是语句  函数返回带有select数据的SqlDataReader对象
        public SqlDataReader read(string sql)
        {
            return command(sql).ExecuteReader();
        }




}
}
